package com.soundShape.utils
{
	
	import __AS3__.vec.Vector;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.printing.PrintJob;
	import flash.printing.PrintJobOptions;
	import flash.printing.PrintJobOrientation;
	import flash.system.Capabilities;
	
	import flashx.textLayout.conversion.TextConverter;
	import flashx.textLayout.elements.TextFlow;
	
	import mx.collections.ArrayCollection;
	import mx.collections.ICollectionView;
	import mx.controls.Alert;
	import mx.core.IUIComponent;
	import mx.managers.PopUpManager;
	import mx.printing.FlexPrintJob;
	import mx.printing.FlexPrintJobScaleType;
	import mx.resources.Locale;
	
	import spark.utils.TextFlowUtil;
	
	
	
	
	
	public class PrintUtil
	{
		private var printJob:PrintJob;
		
		
		[Bindable] private var lastError:String = "";
		
		[Bindable] private var printersData:ArrayCollection;
		
		[Bindable] public var paperData:ArrayCollection = new ArrayCollection([
			{label:"Letter", data:"letter", w:612, h:792},
			{label:"Legal", data:"legal", w:612, h:1008},
			{label:"A4", data:"a4", w:595, h:842},
			{label:"A5", data:"a5", w:420, h:595},
			{label:"A6", data:"a6", w:297, h:420},
			{label:"B5 (Japan)", data:"jis_b5", w:516, h:729},
			{label:"B5 Envelope", data:"env_b5", w:499, h:709},
			{label:"#10 Envelope", data:"env_10", w:297, h:684},
			{label:"Monarch Envelope", data:"env_monarch", w:279, h:540},
			{label:"(Other)", data:"OTHER", w:0, h:0} ]);
		
		public function PrintUtil()
		{
		}
		
		public function initPrinter(printContent:Sprite):void
		{
			printJob = new PrintJob();
			
			if(printJob.start() != true) return;
			
			printJob.addPage(printContent,null,null);
			
			printJob.send();
			
		}
		
		public function initFlexPrinter(printContent:IUIComponent):void
		{
			var flexPrintJob:FlexPrintJob = new FlexPrintJob();
			
			flexPrintJob.addObject(printContent, FlexPrintJobScaleType.MATCH_WIDTH);
			
			if(flexPrintJob.start() != true) return;
			
			flexPrintJob.send();
			
		}
		
	}
}